<html>
<!--
 Copyright (C) 2017, 2018 XStream committers.
 All rights reserved.
 
 The software in this package is published under the terms of the BSD
 style license a copy of which has been included with this distribution in
 the LICENSE.txt file.
 
 Created on 3. May 2017 by Joerg Schaible
 -->
  <head>
    <title>CVE-2016-3674</title>
  </head>
  <body>

    <h2 id="vulnerability">Vulnerability</h2>
    
    <p>CVE-2016-3674: XML External Entity (XXE) Vulnerability in XStream.</p>
	
    <h2 id="affected_versions">Affected Versions</h2>
    
	<p>XStream is not vulnerable, if the default XML Pull Parser is used (Xpp3 or kXML2), since these parser types do
	not process XML entities at all.</p>
	
	<p>All versions until and including version 1.4.8 are affected, if they use explicitly one of the following parsers:</p>
	<ul>
		<li>DOM4J</li>
		<li>DOM</li>
		<li>JDOM</li>
		<li>JDOM2</li>
		<li>StAX implementation</li>
		<li>XOM</li>
	</ul>
	
	<p>XStream's HierarchicalStreamDriver implementations will now explicitly turn off the processing of external
	entities, but the setting is not respected by all parser implementations.	XStream stays therefore vulnerable in
	future, if one of the following parser implementations is explicitly used:</p>
	<ul>
		<li>DOM implementation from Java 5 runtime and below</li>
		<li>StAX implementation from Java 6 runtime and below</li>
		<li>StAX implementation from BEA (old reference implementation)</li>
		<li>XOM</li>
	</ul>
	
	<p>See <a href="faq.html#Security_XXEVulnerability">FAQ</a> for a matrix explaining some parser behavior.</p>

    <h2 id="description">Description</h2>
    
    <p>XStream supports a lot of different XML parsers. Some of those can also process external entities which was
    enabled by default.  An attacker could therefore provide manipulated XML as input to access data on the file
    system, see <a href="https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing">XXE Vulnerability</a>.</p>

    <h2 id="reproduction">Steps to Reproduce</h2>

	<p>An attacker might use external general or parameter entities:</p>
<div class="Source XML"><pre>&lt;?xml version=&quot;1.0&quot;&gt;
  &lt;!DOCTYPE root [
    &lt;!ELEMENT string (#PCDATA)&gt;
    &lt;!ENTITY content SYSTEM &quot;file:/etc/passwd&quot;&gt;
]&gt;&lt;string&gt;&amp;content;&lt;/string&gt;
</pre></div>
<div class="Source XML"><pre>&lt;?xml version=&quot;1.0&quot;&gt;
  &lt;!DOCTYPE root [
    &lt;!ELEMENT string (#PCDATA)&gt;
    &lt;!ENTITY content SYSTEM &quot;file:/etc/passwd&quot;&gt;
    %content;
]&gt;&lt;string&gt;test&lt;/string&gt;
</pre></div>
	<p>Use one of the XML documents above, initialize XStream with a vulnerable parser and unmarshal the XML:</p>
<div class="Source Java"><pre>XStream xstream = new XStream();
String s = (String)xstream.fromXML(xml);
</pre></div>

    <h2 id="impact">Impact</h2>

	<p>The vulnerability may allow a remote attacker to retrieve the content of arbitrary files with known locations in
	a local file system if the Java process has read access.</p>

    <h2 id="workarounds">Workaround</h2>

	<p>Use one of the XML Pull Parser implementations.</p>

    <h2 id="credits">Credits</h2>
    
    <p>The vulnerability was discovered and reported by Alexander Klink.</p>
    
  	</body>
 </html>